package com.littleken.order.message;

import com.littleken.order.dto.OrderDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Component;

/**
 * 消息接收
 */
@Component
@EnableBinding(StreamClient.class)
@Slf4j
public class StreamReceiver {

    /**
     * 接收orderdto
     * @param orderDTO
     */
    @StreamListener(StreamClient.INPUT)
    @SendTo(StreamClient.RETUEN)//返回应答消息
    public String process(OrderDTO orderDTO){
        log.error("StreamReceiver = {}",orderDTO);
        return "-------------received---------------";
    }

    @StreamListener(StreamClient.RETUEN)//接收应答消息
    public void processRETURN(String msg){
        log.error(msg);
    }

}
